﻿using GeneralDashboard.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GeneralDashboard.Pages
{
    /// <summary>
    /// ProtocolDesignerDock.xaml 的交互逻辑
    /// </summary>
    public partial class ProtocolDesignerDock : UserControl
    {
        public ProtocolDesignerDock()
        {
            InitializeComponent();
            List<DataSourceViewModel> dataTypes = new List<DataSourceViewModel>
            {
                new DataSourceViewModel{DataType = typeof(bool), Source="1位布尔值",Title=nameof(Boolean)},
                new DataSourceViewModel{DataType = typeof(sbyte), Source="8位有符号整型",Title=nameof(SByte)},
                new DataSourceViewModel{DataType = typeof(short), Source="16位有符号整型",Title=nameof(Int16)},
                new DataSourceViewModel{DataType = typeof(int), Source="32位有符号整型",Title=nameof(Int32)},
                new DataSourceViewModel{DataType = typeof(long), Source="64位有符号整型",Title=nameof(Int64)},
                new DataSourceViewModel{DataType = typeof(byte), Source="8位无符号整型",Title=nameof(Byte)},
                new DataSourceViewModel{DataType = typeof(ushort), Source="16位无符号整型",Title=nameof(UInt16)},
                new DataSourceViewModel{DataType = typeof(uint), Source="32位无符号整型",Title=nameof(UInt32)},
                new DataSourceViewModel{DataType = typeof(ulong), Source="64位无符号整型",Title=nameof(UInt64)},
                new DataSourceViewModel{DataType = typeof(float), Source="32位浮点数",Title=nameof(Single)},
                new DataSourceViewModel{DataType = typeof(double), Source="64位浮点数",Title=nameof(Double)},
                new DataSourceViewModel{DataType = typeof(string), Source="ASCII字符串",Title=nameof(String)}
            };

            DataList.ItemsSource = new ObservableCollection<DataSourceViewModel>(dataTypes);
        }

        private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (sender is ModernWpf.Controls.ListViewItem)
            {
                ModernWpf.Controls.ListViewItem draggedItem = sender as ModernWpf.Controls.ListViewItem;
                DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Copy);
                draggedItem.IsSelected = true;
            }
        }
    }
}
